<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
</head>

<body>
    <div id="app">
        <input type="text" v-model="inputVal">
        <button @click="handleAdd">add</button>
        <ul>
            <li v-for="item,index in list">
                {{item}}----
                <button @click="handleDel(index)">del</button>
            </li>
        </ul>
    </div>
</body>
<script>
    new Vue({
        el: "#app",
        data: {
            inputVal: "",
            list: [1, 2, 3, 4]

        },
        methods: {
            handleAdd() {
                this.list.push(this.inputVal)
            },
            handleDel() {
                this.list.splice(this.index, 1)
            }
        }
    })
</script>

</html>